package controls.demographic {
	
	import flash.events.Event;
	
	import mx.collections.ArrayCollection;
	import mx.containers.HBox;
	import mx.controls.ComboBox;
	import mx.events.FlexEvent;
	import events.ExperimentEvent;
	
	/**
	 * @author Brent Kersanske
	 */ 
	public class DemographicQuestionClass extends HBox	{
		
		private var _questionText:String;
		
		private var _answers:ArrayCollection;
		
		[Bindable]
		public var answersComboBox:ComboBox;
				
		public function DemographicQuestionClass()	{
			addEventListener(FlexEvent.CREATION_COMPLETE, handleCreationComplete);
		}
		
		private function handleCreationComplete(e:FlexEvent):void {
			
		}

		[Bindable]
		public function set questionText(questionText:String):void {
			_questionText = questionText;
		}
		
		public function get questionText():String {
			return _questionText;
		}

		[Bindable]
		public function set answers(answers:ArrayCollection):void {
			_answers = answers;
		}
		
		public function get answers():ArrayCollection {
			return _answers;
		}
		
		public function get optionSelected():String {
			return this.answersComboBox.selectedLabel;
		}
		
		/**
		 * Event dispatched when a user changes the selected value of the combo box.
		 */ 
		public function handleComboBoxChange(e:Event):void {
			dispatchEvent(new ExperimentEvent(ExperimentEvent.COMBO_CHANGE, true, false));
		}
		
	}
}